<?php
if(!session_start()){session_start();}
if(!$_SESSION['file_slide3']){	$_SESSION['file_slide3'] = "product";}
//if(!$i){	$i = 0;}
if(count($_POST)==0){$_SESSION['file_slide3'] = "product";}
//if((count(explode(',',$_SESSION['file_slide1']))-1)>count($_POST)){$_SESSION['file_slide1'] = "product";}
echo count($_POST);

$result = array();
  
$result['time'] = date('r');
$result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6);
$result['agent'] = $_SERVER['HTTP_USER_AGENT'];
if (count($_GET)) {
	$result['get'] = $_GET;
}
if (count($_POST)) {
	$result['post'] = $_POST;
}
if (count($_FILES)) {
	$result['files'] = $_FILES;

}
 
// we kill an old file to keep the size small
if (file_exists('script.log') && filesize('script.log') > 102400) {
	unlink('script.log');
}
 
$log = @fopen('script.log', 'a');
if ($log) {
	fputs($log, print_r($result, true) . "\n---\n");
	fclose($log);
}
// Validation
$error = false;
 
if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
	$error = 'Invalid Upload';
}

  move_uploaded_file($_FILES['Filedata']['tmp_name'], '../img/product/' . $_FILES['Filedata']['name']);

 // echo $_FILES['Filedata']['name'];

 if($_SESSION['file_slide3']){
  $isfile =  $_SESSION['file_slide3'];
 }
  if ($isfile !=""){$_SESSION['file_slide3'] = $isfile.",".$_FILES['Filedata']['name'];}
  else
  {$_SESSION['file_slide3'] = $_FILES['Filedata']['name'];}
//   echo 
// echo $_FILES['Filedata'];//count($_POST);
if((count(explode(',',$_SESSION['file_slide3']))-1) >= count($_POST))
	 {?>
  <input name="slide" type="text" id="slide" size="50" value="<?php echo $_SESSION['file_slide3'];?>"/><?
	 }
 
 ?>
